<?php
namespace Index\Controller;
use Think\Controller;

class CompanyController extends Controller {

	public function contact(){
		
		//web config
		$getInfo = M('web_config');
		$getConf = $getInfo->find(1);
		$getConf['logo_img'] = '/Public/Uploads/'.$getConf['logo_img'];

		//get category
		$cate = M('category');
		$getTopCate = $cate->where(['pid'=>0])->order('sort asc')->select();

		foreach($getTopCate as &$v){
			$v['sub'] = $cate->where(['pid'=>$v['id']])->select();
		}

		$s = M('company_info');
		$contact = $s->field('contact')->find(1);
		$contact['contact'] = html_entity_decode($contact['contact']);
		$this->assign([
			'getConf'  => $getConf, 
			'contact'  => $contact,
			'getCate'=>$getTopCate, 
		]);
		$this->display();
	}

	//关于我们
	public function about(){


		//web config
		$getInfo = M('web_config');
		$getConf = $getInfo->find(1);
		$getConf['logo_img'] = '/Public/Uploads/'.$getConf['logo_img'];

		$s = M('company_info');
		$brief = $s->find(1);
		$brief['brief'] = html_entity_decode($brief['brief']);
		$brief['enbrief'] = html_entity_decode($brief['enbrief']);

		//get category
		$cate = M('category');
		$getTopCate = $cate->where(['pid'=>0])->order('sort asc')->select();

		foreach($getTopCate as &$v){
			$v['sub'] = $cate->where(['pid'=>$v['id']])->select();
		}


		$this->assign([
			'getConf'  => $getConf,
			'brief'  => $brief, 
			'getCate'=>$getTopCate,
		]);
		$this->display();


	}


	//新闻
	public function news(){

		//web config
		$getInfo = M('web_config');
		$getConf = $getInfo->find(1);
		$getConf['logo_img'] = '/Public/Uploads/'.$getConf['logo_img'];
		
		$n = M('news');
		$news = $n->select();

		//get category
		$cate = M('category');
		$getTopCate = $cate->where(['pid'=>0])->order('sort asc')->select();

		foreach($getTopCate as &$v){
			$v['sub'] = $cate->where(['pid'=>$v['id']])->select();
		}

		$this->assign([
			'getConf'=>$getConf,
			'news'  => $news,
			'getCate'=>$getTopCate,
		
		]);

		$this->display();


	}


	//新闻详情
	public function news_detail(){

		$id = I('get.id');  //获取对应ID
		//web config
		$getInfo = M('web_config');
		$getConf = $getInfo->find(1);
		$getConf['logo_img'] = '/Public/Uploads/'.$getConf['logo_img']; //转换路径
		
		$n = M('news');
		$news = $n->find($id);
		$this->assign([
			'getConf'=>$getConf,
			'news'  => $news,
		
		]);

		$this->display();


	}



}
